package com.springcontext.ioc;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.core.PriorityOrdered;

/**
 * 一辈子只在加载bean 之后调用（注意不是实例化），只调用一次
 */
//@Component
public class BeanFactoryPostProcessorDemo implements BeanFactoryPostProcessor, PriorityOrdered {

  Logger LOGGER = LoggerFactory.getLogger(this.getClass());

  @Override
  public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    LOGGER.warn("容器启动只调用一次, BeanFactoryPostProcessor：" + beanFactory);
  }

  @Override
  public int getOrder() {
    return 0;
  }
}
